let data = {
  name: 'don'
}

let name = ''

function observer(data) {
  Object.defineProperty(data, 'name', {
    get: function() {
      return name
      console.log("先前取的名字是:" + name);
    },
    set: function(value) {
      name = value
      console.log("取了一个name为" + value + "的值");
    }
  })
}

observer(data)
data.name = 'abc'
console.log(data.name);